package com.zbf.file.config;

import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 作者: LCG
 * 日期: 2020/6/16 20:40
 * 描述:
 */
@Configuration
@EnableConfigurationProperties(MinioProperties.class)
public class BeanConfig {

    @Autowired
    private MinioProperties minioProperties;


    /**
     * 创建Minio客户端
     * @return
     * @throws InvalidPortException
     * @throws InvalidEndpointException
     */
    @Bean
    public MinioClient getMinioClient() throws InvalidPortException, InvalidEndpointException {

        return new MinioClient(minioProperties.getUrl(),minioProperties.getAccessKey(),minioProperties.getAccessPass());

    }

}
